package cc.service.impl;

import cc.persistence.PersistenceService;
import cc.service.ServiceException;

import java.util.Optional;
import java.util.ServiceLoader;

/**
 * @Author firefly
 * @since 2018/11/25
 */
public class PersistenceLoader {
    public static PersistenceService persistenceService;

    static {
        final Optional<PersistenceService> optionalService = ServiceLoader.load(PersistenceService.class).findFirst();
        if (optionalService.isPresent()) {
            persistenceService = optionalService.get();
        } else {
            throw new RuntimeException("No persisence service");
        }
    }
}
